package com.binguo.wxapi.controller;

import com.binguo.common.exception.ServiceException;
import com.binguo.model.model.Customer;
import com.binguo.wxapi.form.CreateFaceForm;
import com.binguo.wxapi.form.ImgForm;
import com.binguo.wxapi.result.Result;
import com.binguo.wxapi.result.ResultGenerator;
import com.binguo.wxapi.service.PictureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.binguo.common.exception.ErrorCode.CUSTOMER_NOT_EXIST;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

/**
 * @author yuritian
 * @Title: WXImgController
 * @ProjectName binguoDevelop
 * @Description: TODO
 * @date 2019-05-2013:05
 */
@Api(tags = "图片上传")
@RestController
@RequestMapping
public class WXImgController {
    private static Logger logger = LoggerFactory.getLogger(WXImgController.class);

    @Resource
    PictureService pictureService;

    @PostMapping(value = "/api/wxapp/imgUpload", produces = APPLICATION_JSON_VALUE)
    @ApiOperation(value = "上传图片", notes = "通过ImgForm")
    public Result create(@RequestBody @Valid ImgForm form) {
        return ResultGenerator.genSuccessResult(pictureService.uploadImg(form.getBase64IMG()));
    }

}
